home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-09-11 | 4.6 KB | 163 lines | [TEXT/CWIE] |
- // HFSCorpus.h
- // Copyright: © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
-
- // a corpus implementation for Macintosh HFS files
-
- #pragma once
- #ifndef HFSCorpus_h
- #define HFSCorpus_h
-
- #pragma import on
-
- #include "IACorpus.h"
-
- //#pragma IA_BEGIN_IMPORTS
- #include <Types.h>
- //#pragma IA_END_IMPORTS
-
- #pragma IA_BEGIN_EXPORTS
-
- const uint32 HFSCorpusType = 'HFS0';
-
- /// HFSVolumeInfo
-
- class HFSVolumeInfo : public IAStorable {
- public:
- HFSVolumeInfo() : name(NULL) {}
- HFSVolumeInfo(short vRefNum);
- ~HFSVolumeInfo();
-
-
- // methods to store a HFSVolumeInfo
- IABlockSize StoreSize() const;
- void Store(IAOutputBlock* output) const;
- IAStorable* Restore(IAInputBlock* input) const;
- IAStorable* DeepCopy() const;
-
- short GetVolumeRefNum() const {return vRefNum;}
- StringPtr GetVolumeName() const {return name;}
- long GetCreationDate() const {return creationDate;}
-
- void SetVolumeRefNum(short refNum) {vRefNum = refNum;}
- void SetVolumeName(StringPtr vname) {name = vname;}
- void SetCreationDate(long cDate) {creationDate = cDate;}
-
- private:
- HFSVolumeInfo(short v, StringPtr n, long c) : vRefNum(v), name(n), creationDate(c) {}
- short FindVRefNum(const StringPtr name, long creationDate) const;
-
- HFSVolumeInfo(HFSVolumeInfo&); // don't define a copy constructor
-
- short vRefNum; // volume reference number (ephemeral)
- StringPtr name; // volume name (persistent)
- long creationDate; // volume creation date (persistent)
-
- };
-
- IAExceptionCode HFSVolumeNotFound = 'VCHV';
- IAExceptionCode HFSError = 'VCHE';
-
- class HFSCorpus : public IACorpus {
- public:
- HFSCorpus(uint32 type = HFSCorpusType)
- : volumeInfos(NULL), volumeCount(0), IACorpus(type) {}
- ~HFSCorpus();
-
- // IACorpus methods
- IADoc* GetProtoDoc();
- IADocText* GetDocText(const IADoc* doc);
-
- // HFSCorpus-specific methods
- unsigned short GetVRefID(short vRefNum);
- short GetVRefNum(unsigned short vRefID);
-
- protected:
- IABlockSize InitialSize();
- void Initializing(IAOutputBlock* output);
- void Opening(IAInputBlock* input);
- IABlockSize UpdateSize();
- void Updating(IAOutputBlock* output);
-
- void DeleteVolumeInfos();
-
- void SetVolumeInfos (HFSVolumeInfo** vinfos) {volumeInfos = vinfos;}
- void SetVolumeCount(short vCount) {volumeCount = vCount;}
-
- HFSVolumeInfo** GetVolumeInfos () const {return volumeInfos;}
- short GetVolumeCount() const {return volumeCount;}
-
- private:
- HFSCorpus(HFSCorpus&); // don't define a copy constructor
- HFSVolumeInfo** volumeInfos; // array mapping from vRefID to HFSVolumeInfo
- short volumeCount; // length of the array
-
-
- };
-
- class HFSDoc : public IADoc {
- public:
- HFSDoc(HFSCorpus* corpus, short vRefNum, long dirID, const StringPtr name);
- HFSDoc() : fileName(NULL) {}
- virtual ~HFSDoc();
-
- IAStorable* DeepCopy() const;
- IABlockSize StoreSize() const;
- void Store(IAOutputBlock* output) const;
- IAStorable* Restore(IAInputBlock* input) const;
-
- bool LessThan(const IAOrderedStorable* neighbor) const;
- bool Equal(const IAOrderedStorable* neighbor) const;
-
- byte* GetName(uint32 *length) const;
-
- void SetVolumeRefID(unsigned short vrid) {vRefID = vrid;}
- void SetDirID(long dID) {dirID = dID;}
- void SetFileName(StringPtr name) {fileName = name;}
- unsigned short GetVolumeRefID() const {return vRefID;}
- long GetDirID() const {return dirID;}
- StringPtr GetFileName() const {return fileName;}
-
-
- protected:
- void DeepCopying(const IAStorable* source);
- void Restoring(IAInputBlock* input, const IAStorable* proto);
- private:
- HFSDoc(HFSDoc& fd); // don't define a copy constructor
- unsigned short vRefID; // not a vRefNum! use as arg to GetVRefNum().
- long dirID;
- StringPtr fileName; // alloated with IAMallocArraySized
-
- };
-
- class HFSDocText : public IADocText {
- public:
- HFSDocText() : refNum(0) {}
- HFSDocText(short vRefNum, long dirID, const StringPtr name);
- ~HFSDocText();
-
- uint32 GetNextBuffer(byte* buffer, uint32 bufferLength);
- IADocText* DeepCopy() const;
- protected:
- void SetRefNum (short rNum) {refNum = rNum;}
- void SetTheVolumeRefNum(short vrnum) {theVRefNum = vrnum;}
- void SetTheDirID(long did) {theDirID = did;}
- void SetTheFileName(StringPtr name) {theFileName = name;}
-
- short GetRefNum () const {return refNum;}
- short GetTheVolumeRefNum() const {return theVRefNum;}
- long GetTheDirID() const {return theDirID;}
- StringPtr GetTheFileName() const {return theFileName;}
-
- private:
- HFSDocText(HFSDocText&); // don't define a copy constructor
-
- short refNum;
- short theVRefNum;
- long theDirID;
- StringPtr theFileName;
- };
-
- #pragma IA_END_EXPORTS
-
- #pragma import reset
- #endif